<template>
	<view class="">
		<view class="bj">
			<view class="qbjf">
				{{integral}}
			</view>
			<view class="dqjf">
				我的当前积分
			</view>
		</view>
		<view class="hr"></view>
		<view class="btnbox">
			<view class="jfjl">
				积分记录
			</view>
			<view class="dhbox" v-for="(item,index) in list" :key="index">
				<view class="leftbox">
					<view class="duihuan">
						{{item.remarks}}
					</view>
					<view class="time">
						{{item.create_time}}
					</view>
				</view>
				<view class="rightbox" v-if="(item.integral)*1<0">
					{{item.integral}}
				</view>
				<view class="rightboxs" v-if="(item.integral)*1>0">
					+{{item.integral}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getmyintegrallist} from "../../api/api/index.js"
	export default{
		data(){
			return{
				flag:false,
				limit:20,
				page:0,
				list:[],
				// 积分
				integral:0
			}
		},
		methods:{
			public(){
				if(this.flag){
					return uni.showToast({
						title:"没有更多了",
						icon:"none",
						duration:1500
					})
				}
				this.page++
				let data={limit:this.limit,page:this.page}
				uni.showLoading({
					title:"加载中",
					mask:true
				})
				getmyintegrallist(data).then(res=>{
					uni.hideLoading()
					this.list=this.list.concat(res.data.data)
					this.integral=res.data.integral
					if(res.data.length<this.limit){
						this.flag=true
					}
				})
			}
		},
		onShow() {
			this.page=0
			this.flag=false
			this.list=[]
			this.public()
		},
		onReachBottom(){
			this.public()
		}
	}
</script>

<style scoped lang="scss">
	.bj {
		width: 100%;
		height: 232rpx;
		background-color: #fc4f4f;
		padding-top: 50rpx;
		padding-bottom: 50rpx;
		box-sizing: border-box;

		.qbjf {
			text-align: center;
			font-family: PingFang-SC-Heavy;
			font-size: 60rpx;
			color: #ffffff;
		}

		.dqjf {
			text-align: center;
			font-family: PingFang-SC-Medium;
			font-size: 24rpx;
			color: #ffffff;
		}
	}

	.hr {
		height: 15rpx;
		background-color: #ededed;
		width: 100%;
	}

	.btnbox {
		padding: 30rpx 20rpx;
		box-sizing: border-box;
		background-color: #FFFFFF;

		.jfjl {
			font-family: MicrosoftYaHei-Bold;
			font-size: 30rpx;
			color: #000000;
			font-weight: 700;
		}

		.dhbox {
			display: flex;
			justify-content: space-between;
			margin-top: 53rpx;

			.leftbox {
				.duihuan {
					font-family: MicrosoftYaHei;
					font-size: 26rpx;
					color: #000000;
				}

				.time {
					font-family: MicrosoftYaHei;
					font-size: 22rpx;
					color: #999999;
					margin-top: 15rpx;
				}
			}

			.rightbox {
				font-family: PingFang-SC-Heavy;
				font-size: 30rpx;
				color: #0c91f7;
			}

			.rightboxs {
				font-family: PingFang-SC-Heavy;
				font-size: 30rpx;
				color: #cc0000;
			}
		}
	}
</style>
